<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\SArticleInfo as ArticleModel;

class ArticleController extends BaseController
{
     //获取文章列表
    public function getArticleList()
    {
    	$list = ArticleModel::getList();

    	return $this->outPutSucc($list);
    }

    //获取单个文章
    public function getOneArticleById()
    {
    	$article_id = intval( request("articleId") );
        
    	if($article_id > 0) {
            $ret = ArticleModel::find($article_id);
            if($ret) {
                // $this->addLookNum($ret);
                return $this->outPutSucc($ret);
            }
    	}
        return $this->outPutErr("无效的文章id！");
    }

    //添加观看次数
    protected function addLookNum($article)
    {
        $article->look_num ++;
        $article->save();

        //记录学生阅读？？
        //
    }
}
